Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Issue#98: refactor test suite #294

Closed

Conversation

gyermolenko
Copy link
Contributor

@gyermolenko gyermolenko commented Oct 6, 2018

Disclaimer: work in progress. I need initial review to proceed.

Main points:

  • split tests by topics (instantiation, contents, comparisons)
  • create parametrized fixtures - all 4 types of instances ([MultiDict, CIMultiDict, MultiDictProxy, CIMultiDictProxy]) are pre-created and used for tests which concern not instantiation of those classes themselves
    (unfortunately, pytest so far [doesn't support fixtures in pytest.mark.parametrize] )(Using fixtures in pytest.mark.parametrize pytest-dev/pytest#349)
  • use autouse=True class level hack (since we can't use __init__) to be able to use self.d instead of long fixture names.

Since my goal is restructuring - I didn't touch asserts themselves. I think that such comments can be addressed after the fact.

@codecov

This comment has been minimized.

@gyermolenko

This comment has been minimized.

@asvetlov

This comment has been minimized.

class TestContents:

@pytest.fixture(autouse=True)
def _autoassign_md_to_d(self, md_w_multivalue_per_key):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the parametrization approach but this particular fixture looks like a hack.

Instead of self.d we can always use a fixture for multidict instance explicitly.
This allows getting rid of self.d entirely.
self.d is necessary for unittest based approach but redundant for pytest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, classes are normally not necessary. If you need namespacing, flat is better than nested: just use separate test modules :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree but I don't insist.
Can live with classes if they are already exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but classes often implicitly encourage ppl to have state. Which might lead to tests depending on each other. Why rely on human reviewers to catch those when simple rules are more effective in terms of discouraging this? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is getting rid of classes the suggestion or requirement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion. A requirement would need actual linting implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(But still, it's also: simple is better than complex)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webknjaz regarding classes -> modules part:
I mostly agree but it is hard to split something in modules when you don't actually know all parts.
Like here I am still in progress figuring out the layout and all needed fixtures.
When it is settled - I will probably come back to that thought.

assert list(d.items()) == []

assert cls() != list()
with pytest.raises(TypeError, match='\(2 given\)'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use raw-string literals instead of escaping everything

@gyermolenko
Copy link
Contributor Author

hey, @asvetlov @webknjaz
I've updated this PR and my first comment.
Please review and leave your comments :)

@gyermolenko
Copy link
Contributor Author

hey @asvetlov , just a friendly ping.
It would be nice to have your comments on updated PR

@webknjaz webknjaz closed this Nov 25, 2019
@webknjaz webknjaz reopened this Nov 25, 2019
@webknjaz webknjaz added the bot:chronographer:skip This PR does not need to include a change note label Sep 22, 2022
@webknjaz webknjaz closed this Sep 22, 2022
@webknjaz webknjaz reopened this Sep 22, 2022
@webknjaz webknjaz marked this pull request as draft September 22, 2022 16:36
@webknjaz
Copy link
Member

If this is still relevant after #915, please recreate the PR with those fixtures.

@webknjaz webknjaz closed this Jan 14, 2024
@webknjaz webknjaz linked an issue Jan 17, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:skip This PR does not need to include a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor test suite
3 participants